import scala.io.StdIn
import scala.util.control.Breaks._
object lesson04 {
  def main(args: Array[String]): Unit = {
    //2. 定义变量, 记录用户录入的账号和密码
    var username = ""
    var password = ""
    breakable(
      for (i <- 1 to 3) {
        val username = StdIn.readLine()
        val password = StdIn.readLine()
        if (username == "itcast" && password == "hello") {
          println("登陆成功!")
          break()
        } else {
          i == i + 1
          if (i == 3) {
            println("尝试次数超标！!")
            break()
          }
          println(s"账号或者密码错误!你已经输入${i}次，还剩${3 - i}次!")
        }
      }
    )
  }
}
